<?php
/**
 * @category 	MemberDao.php
 * @author 		Sung Hoon, Cho (akdddnet@gmail.com)
 * @since		2011. 5. 2.
 * @license		BSD License
 * @version		0.1
 */
 
global $CFG;
require_once $CFG->FW_DIR."/mvc/Dao.php";
 
class MemberDao extends Dao {
	
 	function __construct(array $db_type = null) {
 		parent::__construct($db_type);	
 	}
 	
	function view(DTO $dto) {
 		$query ="
 				SELECT		*
 				FROM 		member
 				WHERE		1 = 1
 				AND			m_seq = :m_seq
 		";
 		
 		$bind = array(
 				"m_seq"=>$dto->eb->m_seq
 		);
 		
 		$dto->obj = $this->db->query($query, $bind)->fetch();
 		
 		return $dto;
 	}
 	
 	function getMID(DTO $dto) {
 		$query = "
 				SELECT
 							COUNT(*)
 				FROM		member
 				WHERE		1 = 1
 				AND			m_id = :m_id
 		";
 		
 		$bind = array(
 				"m_id"=>$dto->eb->m_id
 		);
 		
 		$dto->obj = $this->db->query($query, $bind)->field();
 		
 		return $dto;
 	}
 	
 	function doLogin(DTO $dto) {
 		$query = "
 	 	 			SELECT 
 	 	 					*
 	 	 			FROM	member
 	 	 			WHERE	1 = 1
 	 	 			AND		m_id = :m_id
 	 	 			AND		m_password = password(:m_pwd) 
 	 	 		";
 	
 		$bind = array(
 	 	 				 ":m_id"=>$dto->eb->m_id
 		,":m_pwd"=>$dto->eb->m_password
 		);
 	
 		return $this->db->query($query, $bind)->fetch();
 	}
 	
}